SPI PROTOCOL ANALYSER

Overview

The SPI Protocol Analyzer model allows you to monitor and interact with an SPI interface. The protocol analyzer not only allows you to view data sent along the SPI bus but also lets you  send data directly onto the bus. The terminal can operate in one of three modes:

  • Slave Mode: The terminal behaves like a slave SPI device.
  • Master Mode: The terminal behaves like a master SPI device.
  • Monitor Mode: The terminal merely reports on what is being sent across the SPI bus.

The Schematic Part

The schematic part for the SPI Protocol Analyzer is shown below :

Pin Descriptions

SCK Pin:

The SCK pin is a bi-directional pin which is connected to the clock line of your SPI bus, in slave mode it behaves as an input, in master mode as an output

DIN Pin:

DIN is the data input to the terminal model from the SPI data bus.

DOUT Pin:

DOUT is the data output from the terminal model to the SPI bus.

SS Pin:

SS is the slave select pin, in slave mode this must be active for the terminal to respond, in master mode this pin goes active whilst data is being transmitted

TRIG Pin:

TRIG is an input that places the next stored sequence into the SPI output queue

The SPI Debugger Window

When a simulation is paused or free running the Protocol Analyzer window will become available (if it does not automatically appear it can be launched from the Debug Menu in ISIS). This screen is split into several areas and allows you not only to monitor the activity on the SPI bus but also to stimulate the bus either as a Master or Slave device.

 

 Input Data Display

The main window area (the top left portion of the popup) shows you all the activity recorded on the bus. As can be seen from the example above you can drill down to the level of viewing individual bit transmissions.  

When viewing at byte level or higher the time of the start and the stop of the sequence is recorded. When viewing at bit level both the logic state of the pins and the bit designator is recorded in the display alongside the time.

While not visible on the screenshot above the arrows are bi-directional to indicate transmission or reception of data (reception in the case above) and the arrow itself will appear with a question mark if an invalid sequence is detected. This, together with the ability to drill down into individual bit data is invaluable when debugging potential problems.

 Predefined Sequences List

The predefined sequences list at the top right displays a queue of pre-programmed data sequences that can be transmitted onto the bus. You can add a pre-defined sequence by typing in the Sequence Entry Box as described below (use the Add button to commit the sequence to this list).

Double clicking on a predefined sequence  (or highlighting the predefined sequence and clicking on the Queue control button) while the simulation is running will add that sequence to the Buffered/Queued Sequence list for transmission on the bus. Note that the time for transmission depends on bus activity, whether we are a master or slave device etc. and so may well not be instantaneous

 Buffered / Queued Sequences List

The buffered sequences list is gated on the 'Hide Queued Sequences' checkbox and opens to the right of the Input Data Display when activated. It displays a queue of sequences that will be transmitted by the SPI terminal at the next available opportunity. You can add a buffered sequence by typing in the Sequence Entry Box as described below (Use the Queue button to commit the sequence to this list).

 Sequence Entry Box

This box (near the bottom right of the window) allows you to enter sequences to either places on the programmed sequence list or to immediately place on the output queue to be sent to the DOUT pin at the next available opportunity. The following syntax is supported.

Syntax Description

'0x'

Can be used as a prefix to denote hexadecimal values (e.g 0xFE)

'$'

Can be used as a prefix to denote hexadecimal values (e.g %FE)

'h'

Can be used as a prefix to denote hexadecimal values (e.g FEh)

'%'

Can be used as a prefix to denote binary values (e.g %1101)

'b'

Can be used as a prefix to denote binary values (e.g 1101b)

'd'

Can be used as a prefix to denote decimal values (e.g 47d)

Note that hexadecimal and binary values must have either a prefix or suffix qualifier. The decimal suffix is optional. Strings must be enclosed in either double or single quotation marks.

Use the Control Buttons to determine whether a given sequence is added to the Pre-defined Sequence List or to the Buffered/Queued Sequence List

 Control Buttons

The control buttons are used to allow you to provide stimulus to the SPI bus. The protocol analyzer is fully capable of acting as either a master or as a slave device so this provides an invaluable way of testing your SPI implementation.

Add Button

Use this to commit a sequence defined in the Sequence Entry Box to the Pre-defined sequences list for later use.

Delete Button

Use this to delete a sequence in the Pre-defined sequences list.

Queue Button

Use this button to queue selected items either directly from the Sequence Entry Box or from the Pre-defined Sequence List. Queued items will then appear in the Buffered/Queued Sequences List.

Arm Input Display

When selected data will stream to the input display. Since there can be a great deal of traffic this checkbox is intended to be used as a filter. Notably, during a debugging session, one might disarm the display until a relevant breakpoint is hit before arming the display and single stepping through the communication code. Leaving the checkbox selected all of the time will impact simulation performance.

Hide Queued Sequences

When selected the queued sequences window will be hidden. This is the default since the most common configuration is a simple bus monitor where it is not relevant.

Model Properties

The SPI Debugger has a number of properties which allow you to configure it as required. All properties are accessible via the Edit Component dialogue form (right click on the schematic part to highlight and then left click to edit). Details of individual properties are given below :

Property Description

WORDLENGTH

Specified the number of bits in each word transferred. This can be any value from 1 to 16 inclusive.

BITORDER

Specifies the bit order of each word transferred. This can be MSB first of LSB first.

SAMPLEEDGE

Specifies if the sampling of the DIN pin is made when SCK goes from idle to active or when SCK transitions from active to idle.

IDLESTATE

Specifies if SCK is idle when high or when low.

STOPONEMPTY

Indicates if the simulation should be paused when the output buffer is empty.

SEQUENCE_FILE

Allows you to specify the file name of the text file where predefined output sequences are stored. If this property is left blank sequences are stores as part of the devices properties.

MODE

Controls the selection of master or slave mode.

CLOCKFREQ

In master mode  this controls the clock frequency on SCK.

AUTOLOAD

Controls if the predefined sequences are immediately placed into the sequence queue upon simulation start-up.

WRAPLENGTH

Specifies the number of owrds permitted on a single line before a new line is created.

TIMEPREC

The number of decimal places by which time is to be displayed.

DATAINVERT

Indicates if the date on DOUT and DIN is to be inverted.

LOOPBACK

When enabled any received word is queued for transmission.

Using the SPI Debugger

To receive data with the SPI Debugger:

Viewing data on the SPI bus requires that you connect the SCK and DIN pins of the terminal to the relevant pins in your design, then set the word length, bit order, SCK idle state and sampling edge properties of the terminal model. Data on the SPI bus will be displayed in the upper left hand side of the terminal window as hexadecimal values. If a received data word is incomplete, such that SS becomes inactive before a whole word is received, asterisks will be displayed instead of a hexadecimal value.

If bits of a received data word on DIN were floating of in contention then question marks will be displayed instead of a hexadecimal value.

To transmit data with the SPI Debugger:

Sending data over the SPI bus requires that you connect the SCK and DOUT pins of the terminal to the relevant pins in your design, then set a word length bit order, SCK idle state and sampling edge properties of the terminal model.

Transmission data entry is done in the lower right hand side of the terminal window, just above the buttons (See Sequence Entry Box above). Entries can be single words, comma or space separated sequences of words, or text strings enclosed in double or single quotation marks. Word values can be in decimal, hexadecimal or binary. Hexadecimal values are denoted by either a '0x' or '$' prefix, or by a 'h' suffix. Binary values are denoted by a '%' prefix or a 'b' suffix. Decimal values need neither a prefix or suffix but may optionally have a 'd' suffix.

Once you have entered your transmission sequence you may either directly queue the data sequence to be sent or have the data sequence placed on the predefined sequences list for later use. To immediately place the transmission sequence onto the buffered sequences list press the queue button, to place the transmission sequence into the predefine sequences list press the add button.

To place a copy of one of the predefined sequences into the buffered sequences queue, ensure the sequence entry box is empty, select the predefined sequence then press the queue button.

To remove an entry from the predefined sequences, select the predefined sequence to be removed, then press the delete button.

You can dock the SPI window by dragging it to the border of the editing area. This has the advantage of clearing the editing window from obstructions but may limit vertical data. You can undock via the icon at the top right (when docked) and close / open from the command on the Debug menu.